package com.Homework2;

import java.util.*;

public class Test09 {
    public static void main(String[] args) {
        HashMap<String, Float> map = new HashMap<>();
        int count=1;
        while (map.size()<5){
            float rd = new Random().nextInt(100) + 1;
            System.out.println("请输入第"+(count)+++"个学生：");
            String str = new Scanner(System.in).nextLine();
            map.put(str,rd);
        }
        System.out.println(map);
        Set<Map.Entry<String, Float>> entries = map.entrySet();
        Iterator<Map.Entry<String, Float>> iterator = entries.iterator();
        double sum=0;
        double min=iterator.next().getValue(); //低分
        double max=iterator.next().getValue();//高分
        while (iterator.hasNext()){
            Float aFloat = map.get(iterator.next().getKey());//映射 key->value
            sum+=aFloat;
            if(max<aFloat){
                max=aFloat;
            }
            if(min>aFloat){
                min=aFloat;
            }
        }
        System.out.println("最高分为:"+max+",最低分为:"+min+",平均分为"+(sum/map.size()));
    }
}
